home *** CD-ROM | disk | FTP | other *** search
- Path: unixg.ubc.ca!news
- From: jamesdf@unixg.ubc.ca (James Fairweather)
- Newsgroups: comp.lang.c
- Subject: Re: Can anyone HELP with variable delaration? Please?
- Date: Wed, 03 Apr 1996 20:44:57 GMT
- Organization: University of British Columbia
- Message-ID: <3162de71.18703379@news.ucs.ubc.ca>
- References: <4jt07b$dul@news.us.net> <3162119a.43634755@news.ucs.ubc.ca> <4juf2kINNe9v@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: srtb0411a01.resnet.ubc.ca
- X-Newsreader: Forte Agent .99d/32.182
-
- >Any variable can be declared constant, including strings:
- >
- > const char * const str = "Foo";
- >
- >Or do you mean literal constants?
- >
- I'm not sure what the difference is. I thought the keyword "const"
- was just for the compiler. If you tried to modify the variable
- declared const, the compiler would complain. Does it do something
- else with the variable if you declare it const?
-
- >In what way are integers a suitable alternative representation for string data?
- >--
- I guess I was being too extreme. It's just that in high school, when
- we were coding with Pascal, we were encouraged to use strings
- whereever possible. Don't ask me why; it never occurred to me to ask
- at the time. And sometimes when I read other people's code,
- espeically people who are used to Pascal, I often see them using
- strings in an if...else situation. In these cases, a well-name
- #defined constant works better, because you can use switch and the
- comparison is faster.
- ---
- James Fairweather
- 4th year Comp. Eng, UBC
- Vancouver, BC, Canada
- jamesdf@unixg.ubc.ca
- 604.228.2269
-